package com.rtx.wms.std.common.mapper;

import com.rtx.wms.std.common.bean.PlDb;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommonMapper {

    /**
     * 获取WMS订单号
     * @param keyname
     */
    @Select("select keycount from ncounter where keyname=#{keyname}")
    Integer selectWmskey(@Param("keyname")String keyname);

    /**
     * 插入NCOUNT
     * @param keyname
     */
    @Insert("insert into ncounter (keyname,keycount) values (#{keyname},2)")
    void insertNcounter(@Param("keyname")String keyname);

    /**
     * 更新NCOUNT
     * @param keyname
     */
    @Update("update ncounter set keycount=keycount+1 where keyname=#{keyname}")
    void updateNcounter(@Param("keyname")String keyname);

    /**
     * 获取激活的仓库
     * @return
     */
    @Select("select db_logid from pl_db where isactive=1")
    List<String> selectActiveWhseid();

    /**
     * 获取激活的仓库(不包含企业级)
     * @return
     */
    @Select("select db_logid from pl_db where db_logid<>'enterprise' and isactive=1")
    List<String> selectActiveWhseidNotEnterprise();

    /**
     * 根据仓库编号获取激活的仓库
     * @return
     */
    @Select("select db_logid,isactive from pl_db where isactive=1 and db_logid=#{db_logid}")
    PlDb selectActiveWhseidByDblogid(@Param("db_logid") String db_logid);

    /**
     * 执行SQL
     * @param sql sql语句
     * @return 返回sql执行结果
     */
    @Select("${sql}")
    Object executeSql(String sql);
}
